<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function getNum(min, max) {
      return  Math.floor(Math.random() * (max - min + 1)) + min 
    }

    var result = getNum(1, 3)
    var num = 3 

    while(num--) {  
      var value = parseInt(prompt('请输入一个数'))
      if(value > result) {
        alert('猜大了')
      } else if(value < result) {
        alert('猜小了')
      } else {
        alert('猜对了')
        break
      }
    }

    if(num === -1) {
      alert('智障')
    }
  </script>
</body>
</html>